package pathfinding

import "sync"

type LayerJPS struct {
	Navigable map[int]map[int]int
	Instance  JPSInterface
	Dijkstra  *Dijkstra

	resultQueue    sync.Pool
	jpsQueue       sync.Pool
	multiQueue     sync.Pool
	multiPairQueue sync.Pool
}

func NewLayerJPS(instance JPSInterface, navigable map[int]map[int]int) *LayerJPS {
	ljps := &LayerJPS{
		Navigable: navigable,
		Instance:  instance,
		Dijkstra:  NewDijkstra(),

		resultQueue: sync.Pool{New: func() interface{} {
			return []Vector2{}
		}},
		jpsQueue: sync.Pool{New: func() interface{} {
			return NewJPS(instance)
		}},
		multiQueue: sync.Pool{New: func() interface{} {
			return []*LinkNode{}
		}},
		multiPairQueue: sync.Pool{New: func() interface{} {
			return []*multiPair{}
		}},
	}
	return ljps
}
